﻿using System;
using Deployment.BuildManager.ExternalProcess.Common;
using System.Threading;


namespace TestTasks
{
    class Program
    {
        static void Main(string[] args)
        {
            Deployment.BuildManager.ExternalProcess.GetSource.BuildTask task1 = new Deployment.BuildManager.ExternalProcess.GetSource.BuildTask();
            Deployment.BuildManager.ExternalProcess.GetCompiledAssemblies.BuildTask task2 = new Deployment.BuildManager.ExternalProcess.GetCompiledAssemblies.BuildTask();
            Deployment.BuildManager.ExternalProcess.CreatePackage.BuildTask task3 = new Deployment.BuildManager.ExternalProcess.CreatePackage.BuildTask();
            Deployment.BuildManager.ExternalProcess.CreateXml.BuildTask task4 = new Deployment.BuildManager.ExternalProcess.CreateXml.BuildTask();
            Deployment.BuildManager.ExternalProcess.Compiler.BuildTask task5 = new Deployment.BuildManager.ExternalProcess.Compiler.BuildTask();
            Deployment.BuildManager.ExternalProcess.CheckInAssemblies.BuildTask task6 = new Deployment.BuildManager.ExternalProcess.CheckInAssemblies.BuildTask();

            Deployment.BuildManager.ExternalProcess.Common.SetupInfo info = new Deployment.BuildManager.ExternalProcess.Common.SetupInfo();

            task1.MessageReceived += new EventHandler<Deployment.BuildManager.ExternalProcess.Common.MessageEventArgs>(task_MessageReceived);
            task2.MessageReceived += new EventHandler<Deployment.BuildManager.ExternalProcess.Common.MessageEventArgs>(task_MessageReceived);
            task3.MessageReceived += new EventHandler<Deployment.BuildManager.ExternalProcess.Common.MessageEventArgs>(task_MessageReceived);
            task4.MessageReceived += new EventHandler<Deployment.BuildManager.ExternalProcess.Common.MessageEventArgs>(task_MessageReceived);
            task5.MessageReceived += new EventHandler<Deployment.BuildManager.ExternalProcess.Common.MessageEventArgs>(task_MessageReceived);
            task6.MessageReceived += new EventHandler<Deployment.BuildManager.ExternalProcess.Common.MessageEventArgs>(task_MessageReceived);

            info.CompiledUri = "$/SinaCLI/HotFix/NET/1.9.65537.0";
            info.TemplateProjectUri = "$/Deployment/NET/DEV/CDSC/VN/Source/BuildManager/ExternalProcess/CreateSetupFile";
            //info.SetupUri = "$/SINACOR/Setup/SinacorMAIN_InfraMAIN/1.10.0.1277"; 
            info.SetupUri = @"C:\DSEPROJ\SINACOR\Setup\SinacorMAIN_InfraMAIN\1.10.0.1277";
            info.DownloadPath = @"C:\Empacotador\BMF_1.10.3.0";
            info.ProductName = "Sinacor";
            info.ModuleName = "CLI";
            info.PackageTitle = "Teste CLI";
            info.Version = new PSE.Framework.Common.Version("1.10.3.0");
            
            //Validar valores na interface

            //Download do projeto template.
            task1.Execute(info);

            //Copia arquivos para pasta de resource.
            task2.Execute(info);

            //Copia os compilados para pasta resource do template\gera resources.xml\altera csproj
            task3.Execute(info);

            //Cria o template do XML
            task4.Execute(info);

            //Compila o projeto.
            task5.Execute(info);

            //Check-in
            //task6.Execute(info);
        }

        static void task_MessageReceived(object sender, Deployment.BuildManager.ExternalProcess.Common.MessageEventArgs e)
        {
            Console.WriteLine(e.Message);
        }
    }
}
